﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="left.aspx.cs" Inherits="admin_left" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" style="height: 100%;">
<head runat="server">
    <title></title>
    <script src="../Scripts/jQuery1.7.js" type="text/javascript"></script>
    <link href="Css/frame.css" rel="stylesheet" type="text/css" />
    <style type="text/css">
        .RowTitle
        {
            background-image: url("images/main_47_1.gif");
            height: 23px;
            margin-top: 10px;
            cursor: pointer;
        }
        .RowTitle a
        {
            color: #fff;
            text-shadow: 1px -1px 0 rgba(33, 79, 183, 0.7);
            font-weight: bold;
        }
        .RowOption
        {
            height: 25px;
        }
    </style>
    <script language="javascript" type="text/javascript">
        //页面加载
        $(function () {

            //初始化 深度为1、2的菜单
            var depth1 = $("#List_table>tbody>tr[depth=1]");  //获取深度为1的对象
            var depth2 = $("#List_table>tbody>tr[depth=2]"); //获取深度为2的对象
            depth1.show();
            depth2.show();
            depth1.find("img").attr("src", "Images/2.png");  //让当前的图片改为“已打开”状态
            depth1.removeClass("RowOption");                //让深度为1的对象删除 RowOption
            depth1.addClass("RowTitle");                    //让深度为1的对象添加 RowOption
            depth1.attr("state", "true");                    //修改当前状态为“已打开”
            depth1.bind("click", function (e) {
                TreeOpenOrClose($(this).attr("id"), $(this).find("td>div>span"));

            });

            //给所有菜单绑定单击事件（点击时，添加绿对√。做为当前选中状态）
            $("#List_table>tbody>tr").find("a").bind("click", function () {
                var obj = $(this);
                if (obj.parents("tr:first").attr("depth") != "1") {
                    $(".img_gou").remove();
                    var img = $("<img>");   //创建img容器
                    img.attr("src", "Images/gou.jpg");
                    img.attr("class", "img_gou");
                    img.height(12);
                    img.width(15);
                    obj.after(img);
                }
            });
        })

        //鼠标在元素上时添加样式
        var addClass = function (o) {
            $(o).addClass("move");
        }

        //鼠标移开元素时删除样式 
        var removeClass = function (o) {
            $(o).removeClass("move");
        }

        //树结点展开
        var TreeOpenOrClose = function (pid, obj) {
            var parentObj = $(obj).parents("tr");

            //如果当前状态为未展开状态 执行展开
            if (parentObj.attr("state") == "false") {
                $("tr[name=" + pid + "]").show();           //让父类为自己的分类展开
                $(obj).find("img").attr("src", "Images/2.png");  //让当前的图片改为“已打开”状态
                parentObj.attr("state", "true");                    //修改当前状态为“已打开”
            }
            //如果当前状态为已展开状态，执行合并
            else if (parentObj.attr("state") == "true") {
                $("." + pid).hide();                        //隐藏当前分类的所有子类（包扩自己，下面会执行让自己显示 ）
                $("." + pid).attr("state", "false");        //把当前分类的所有子类状态改为“已合关”
                parentObj.show();                        //让自己显示
                $(obj).find("img").attr("src", "Images/1.png");  //修改当前分类图片为“已合并”图片
                parentObj.attr("state", "false");
            }
        }
    

    </script>
</head>
<body style="height: 100%;">
    <form id="form1" runat="server">
    <div>
        <table id="List_table" style="width: 100%" cellspacing="0" cellpadding="0" border="0">
            <tbody>
                <tr style="height: 5px;">
                    <td>
                    </td>
                </tr>
                <asp:Repeater ID="rpTreeList" runat="server">
                    <ItemTemplate>
                        <tr id="<%#Eval("C_Id")%>" state="false" depth="<%#Eval("C_Depth")%>" name="<%#Eval("C_Parent_Id")%>"
                            class="RowOption <%#Eval("C_Path").ToString().Replace("|"," ")%>" style="display: none;"
                            onmousemove="addClass(this)" onmouseout="removeClass(this)">
                            <td>
                                <div style="margin-left: <%# (Convert.ToInt32(Eval("C_Depth")))*20%>px;">
                                    <span style="cursor: pointer;" onclick="TreeOpenOrClose('<%#Eval("C_Id")%>',this)">
                                        <img src="Images/1.png" /></span> <a href="<%#Eval("C_Url")%>" target="main">
                                            <%#Eval("C_Name")%></a></div>
                            </td>
                        </tr>
                    </ItemTemplate>
                </asp:Repeater>
            </tbody>
        </table>
    </div>
    <%--<div style=" padding-top:5px;">
        <div style=" background-image:url(images/main_47_1.gif); height:23px; ">
        <a id="A1" href="~/admin/system/MenuList.aspx" target="main" runat="server">菜单列表</a>
        </div>
    </div>--%>
    </form>
</body>
</html>
